import axios from "./index";

/**
 * 获取表格数据
 * @returns {AxiosPromise}
 */
export const getTableData = () => {
	return axios.request({
		url: '/getTableData',
		method: 'get'
	})
};

/**
 * 获取所有文件夹列表
 * @returns {AxiosPromise}
 */
export const getFolderList = () => {
	return axios.request({
		url: '/getFolderList',
		method: 'get'
	})
};

/**
 * 获取所有文件列表
 * @returns {AxiosPromise}
 */
export const getFileList = () => {
	return axios.request({
		url: '/getFileList',
		method: 'get'
	})
};

/**
 * 获取上传文件的文件列表
 * @returns {*}
 */
export const getUploadFileList = () => {
	return axios.request({
		url: '/getUploadFileList',
		method: 'get',
		// params: {userId: 1} // 默认用户id=1
	});
}

/**
 * 获取文件
 * @param key
 * @param type
 * @returns {*}
 */
export const getFile = ({key, type}) => {
	return axios.request({
		url: 'getFile',
		data: {key, type},
		method: 'post'
	});
}

/**
 * 删除文件
 * @param key
 * @returns {AxiosPromise}
 */
export const deleteFile = key => {
	return axios.request({
		url: 'deleteFile',
		data: {key},
		method: 'delete'
	})
}

/**
 * 表单提交
 * @param data
 */
/*export const sendFormData = (data) => {
	return axios.request({
		url: '/data/formData',
		data,
		method: 'post'
	});
}*/

export const sendFormData = ({url, data}) => {
	return axios.request({
		url, data, method: 'post'
	});
}
